package org.wesc.boot.dao.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.wesc.boot.common.easyexcel.DoubleToStringConverter;
import org.wesc.boot.common.easyexcel.LocalDateTimeConverter;
import org.wesc.boot.common.easyexcel.LongToStringConverter;
import org.wesc.boot.common.easyexcel.MenuTypeConverter;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 
 * </p>
 *
 * @author Wesley
 * @since 2019-12-09
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("sys_menu")
public class Menu extends Model<Menu> {

    private static final long serialVersionUID = 1L;

    /**
     * 菜单/按钮ID
     */
    @TableId(value = "MENU_ID", type = IdType.AUTO)
    @ExcelProperty(value = {"菜单ID"}, index = 0, converter = LongToStringConverter.class)
    @ColumnWidth(15)
    private Long menuId;

    /**
     * 上级菜单ID
     */
    @ExcelProperty(value = {"父菜单ID"}, index = 2, converter = LongToStringConverter.class)
    @ColumnWidth(15)
    private Long parentId;

    /**
     * 菜单/按钮名称
     */
    @ExcelProperty(value = {"菜单名称"}, index = 1)
    @ColumnWidth(20)
    private String menuName;

    /**
     * 对应路由path
     */
    @ExcelProperty(value = {"路由"}, index = 4)
    @ColumnWidth(25)
    private String path;

    /**
     * 对应路由组件component
     */
    @ExcelProperty(value = {"组件"}, index = 5)
    @ColumnWidth(30)
    private String component;

    /**
     * 权限标识
     */
    @ExcelProperty(value = {"权限"}, index = 6)
    @ColumnWidth(20)
    private String perms;

    /**
     * 图标
     */
    @ExcelIgnore
    private String icon;

    /**
     * 类型 0菜单 1按钮
     */
    @ExcelProperty(value = {"类型"}, index = 3, converter = MenuTypeConverter.class)
    @ColumnWidth(15)
    private String type;

    /**
     * 排序
     */
    @ExcelProperty(value = {"排序"}, index = 7, converter = DoubleToStringConverter.class)
    @ColumnWidth(10)
    private Double orderNum;

    /**
     * 创建时间
     */
    @ExcelProperty(value = {"创建时间"}, index = 8, converter = LocalDateTimeConverter.class)
    @ColumnWidth(30)
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    @ExcelIgnore
    private LocalDateTime modifyTime;


    public static final String MENU_ID = "MENU_ID";

    public static final String PARENT_ID = "PARENT_ID";

    public static final String MENU_NAME = "MENU_NAME";

    public static final String PATH = "PATH";

    public static final String COMPONENT = "COMPONENT";

    public static final String PERMS = "PERMS";

    public static final String ICON = "ICON";

    public static final String TYPE = "TYPE";

    public static final String ORDER_NUM = "ORDER_NUM";

    public static final String CREATE_TIME = "CREATE_TIME";

    public static final String MODIFY_TIME = "MODIFY_TIME";

    @Override
    protected Serializable pkVal() {
        return this.menuId;
    }

}
